package cn.itcast.web.controller;

import cn.itcast.domain.system.User;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/*
该类的作用：把所有Controller公共部门抽取出去，减少重复代码的编写
 */
public class BaseController {


    @Autowired
    protected HttpServletRequest request;

    @Autowired
    protected HttpServletResponse response;

    @Autowired
    protected HttpSession session;


    //获取登陆者的企业id
    public String getLoginUserCompanyId() {
        return getLoginUser().getCompanyId();

    }

    //获取登陆者的企业名称
    public String getLoginUserCompanyName() {
        return getLoginUser().getCompanyName();

    }

    //获取登陆者
    public User getLoginUser(){
        //从session中获取登陆者
        User loginUser = (User) session.getAttribute("loginUser");
        return loginUser;
    }






}




















